/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author Jirka
 */
@Entity
@Table(name = "event")
@NamedQueries({@NamedQuery(name = "Event.findAll", query = "SELECT e FROM Event e"), @NamedQuery(name = "Event.findByEventId", query = "SELECT e FROM Event e WHERE e.eventId = :eventId"), @NamedQuery(name = "Event.findByMatchSecond", query = "SELECT e FROM Event e WHERE e.matchSecond = :matchSecond"), @NamedQuery(name = "Event.findByHomeTeam", query = "SELECT e FROM Event e WHERE e.homeTeam = :homeTeam")})
public class Event implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "event_id")
    @GeneratedValue(strategy=GenerationType.SEQUENCE)
    private Integer eventId;
    @Basic(optional = false)
    @Column(name = "match_second")
    private int matchSecond;
    @Basic(optional = false)
    @Column(name = "home_team")
    private char homeTeam;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "event")
    private Assistance assistance;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "event")
    private Suspension suspension;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "event")
    private Goal goal;
    @JoinColumn(name = "match_id", referencedColumnName = "match_id")
    @ManyToOne(optional = false)
    private Game match;
    @JoinColumn(name = "author_id", referencedColumnName = "player_id")
    @ManyToOne(optional = false)
    private Player author;

    public Event() {
    }

    public Event(Integer eventId) {
        this.eventId = eventId;
    }

    public Event(Integer eventId, int matchSecond, char homeTeam) {
        this.eventId = eventId;
        this.matchSecond = matchSecond;
        this.homeTeam = homeTeam;
    }

    public Integer getEventId() {
        return eventId;
    }

    public void setEventId(Integer eventId) {
        this.eventId = eventId;
    }

    public int getMatchSecond() {
        return matchSecond;
    }

    public void setMatchSecond(int matchSecond) {
        this.matchSecond = matchSecond;
    }

    public char getHomeTeam() {
        return homeTeam;
    }

    public void setHomeTeam(char homeTeam) {
        this.homeTeam = homeTeam;
    }

    public Assistance getAssistance() {
        return assistance;
    }

    public void setAssistance(Assistance assistance) {
        this.assistance = assistance;
    }

    public Suspension getSuspension() {
        return suspension;
    }

    public void setSuspension(Suspension suspension) {
        this.suspension = suspension;
    }

    public Goal getGoal() {
        return goal;
    }

    public void setGoal(Goal goal) {
        this.goal = goal;
    }

    public Game getMatch() {
        return match;
    }

    public void setMatch(Game matchId) {
        this.match = matchId;
    }

    public Player getAuthor() {
        return author;
    }

    public void setAuthor(Player author) {
        this.author = author;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (eventId != null ? eventId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Event)) {
            return false;
        }
        Event other = (Event) object;
        if ((this.eventId == null && other.eventId != null) || (this.eventId != null && !this.eventId.equals(other.eventId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Event[eventId=" + eventId + "]";
    }

}
